<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml">



    <ui:define name="content">       

        <h:panelGroup rendered="true" styleClass="opdPanel" >
            <h:form id="form">

                <p:panel style="min-height: 600px; position:relative;"  >
                    <f:facet name="header" >
                        <h:panelGrid columns="10"  >
                            <h:outputLabel value="Inward Professional Bill" />
                        </h:panelGrid>
                    </f:facet>

                    <h:panelGrid columns="2" >
                        <h:panelGrid columns="1" >
                            <h:panelGroup id="panelPatient" >
                                <p:panel header="Patient Details">
                                    <f:facet name="header">
                                        <p:commandButton value="Clear All" ajax="false" action="#{theatreModuleController.makeNull}"  style="float: right;"></p:commandButton>
                                    </f:facet>
                                    <h:outputLabel value="Type Patient Name or BHT : "/>
                                    <p:autoComplete id="acPt" forceSelection="true" converter="admis"
                                                    value="#{theatreModuleController.admission}" 
                                                    completeMethod="#{admissionController.completePatient}"
                                                    var="apt2" itemLabel="#{apt2.patient.person.name}"
                                                    itemValue="#{apt2}" size="30"  style="width: 400px;">
                                        <p:ajax event="itemSelect" process="acPt" update="panSearch2"/>
                                        <p:column >
                                            #{apt2.bhtNo} 
                                        </p:column>
                                        <p:column >
                                            #{apt2.patient.person.name} 
                                        </p:column>
                                    </p:autoComplete>  
                                    <h:panelGrid id="panSearch2" columns="2" >
                                        <h:outputLabel  rendered="#{theatreModuleController.admission!=null}" value="BHT No : " />
                                        <h:outputLabel rendered="#{theatreModuleController.admission!=null}" value="#{theatreModuleController.admission.bhtNo}" ></h:outputLabel>


                                        <h:outputLabel  rendered="#{theatreModuleController.admission!=null}" value="Patient Name : " />
                                        <h:outputLabel rendered="#{theatreModuleController.admission!=null}" value="#{theatreModuleController.admission.patient.person.nameWithTitle}" ></h:outputLabel>

                                        <h:outputLabel  rendered="#{theatreModuleController.admission!=null}" value="Adress : " />
                                        <h:outputLabel rendered="#{theatreModuleController.admission!=null}" value="#{theatreModuleController.admission.patient.person.address}" ></h:outputLabel>

                                        <h:outputLabel  rendered="#{theatreModuleController.admission!=null}" value="Guardian Name : " />
                                        <h:outputLabel rendered="#{theatreModuleController.admission!=null}" value="#{theatreModuleController.admission.guardian.nameWithTitle}" ></h:outputLabel>

                                        <h:outputLabel  rendered="#{theatreModuleController.admission!=null}" value="Age : " />
                                        <h:outputLabel rendered="#{theatreModuleController.admission!=null}" value="#{theatreModuleController.admission.patient.age}" ></h:outputLabel>
                                        <h:outputLabel  rendered="#{theatreModuleController.admission!=null}" value="Admitted At : "  />
                                        <h:outputLabel rendered="#{theatreModuleController.admission!=null}" value="#{theatreModuleController.admission.dateOfAdmission}"   >
                                            <f:convertDateTime pattern="dd/MM/yy" />
                                        </h:outputLabel>
                                        <h:outputLabel  rendered="#{theatreModuleController.admission!=null}" value="Adress" />
                                        <h:outputLabel rendered="#{theatreModuleController.admission!=null}" value="#{theatreModuleController.admission.patient.person.address}" ></h:outputLabel>
                                    </h:panelGrid>
                                </p:panel>
                            </h:panelGroup>


                            <h:panelGroup id="panelIx" >
                                <p:panel  >
                                    <f:facet name="header"  >
                                        <h:outputLabel value="Surgery Details" >
                                        </h:outputLabel>
                                        <p:commandButton value="Save Procedure" ajax="false" action="#{theatreModuleController.saveProcedure()}" style="float: right;"></p:commandButton>
                                        
                                        <p:commandButton value="New Procedure" ajax="false" action="#{theatreModuleController.newProcedure() }"  style="float: right;"></p:commandButton>
                                    </f:facet>
                                    <p:panelGrid columns="2" >
                                        <h:outputLabel value="Surgery Name" >
                                        </h:outputLabel>
                                        <p:selectOneMenu value="#{theatreModuleController.procedure.item}" >
                                            <f:selectItem itemLabel="Select Surgery" ></f:selectItem>
                                            <f:selectItems value="#{procedureController.items}" var="p" itemLabel="#{p.name}" itemValue="#{p}" ></f:selectItems>
                                        </p:selectOneMenu>
                                        <h:outputLabel value="Surery Date" >
                                        </h:outputLabel>
                                        <p:calendar value="#{theatreModuleController.procedure.dateTime}" pattern="dd MMMM yyyy" >
                                        </p:calendar>
                                        <h:outputLabel value="Start Time" >
                                        </h:outputLabel>
                                        <p:calendar value="#{theatreModuleController.procedure.fromTime}" pattern="dd MMMM yyyy HH:mm:ss" >
                                        </p:calendar>
                                        <h:outputLabel value="End Time" >
                                        </h:outputLabel>
                                        <p:calendar value="#{theatreModuleController.procedure.toTime}" pattern="dd MMMM yyyy HH:mm:ss" >
                                        </p:calendar>
                                    </p:panelGrid>
                                </p:panel>

                                <p:panel id='addStaff' header="Details" style="min-height: 350px;"  >
                                    <p:panelGrid columns="2" id="profPanel">
                                        <h:outputLabel value="Name"/>
                                        <p:inputText autocomplete="off" id="txtName" value="#{theatreModuleController.encounterComponent.name}" ></p:inputText>
                                        <h:outputLabel value="Discreption"/>
                                        <p:inputText autocomplete="off" id="txtDes" value="#{theatreModuleController.encounterComponent.description}" ></p:inputText>
                                        <h:outputLabel  value="Doctor/Staff" ></h:outputLabel>
                                        <p:autoComplete  style="width: 400px;" forceSelection="true" value="#{theatreModuleController.staff}" id="scStaff"
                                                         completeMethod="#{staffController.completeItems}" var="mys" itemLabel="#{mys.person.nameWithTitle}" itemValue="#{mys}"
                                                         converter="stfcon"   >
                                        </p:autoComplete>
                                        <h:outputLabel value="Fee"/>
                                        <p:inputText autocomplete="off" id="prof" value="#{theatreModuleController.encounterComponent.billFee.feeValue}"/>
                                        <h:commandButton value="Add" id="btn" action="#{theatreModuleController.addComponantForAdmissions()}">
                                        </h:commandButton>
                                    </p:panelGrid>
                                </p:panel>

                            </h:panelGroup>

                        </h:panelGrid>


                        <h:panelGrid columns="1" >

                                 <p:dataTable id="panelBillItems" value="#{theatreModuleController.procedure.encounterComponents}" var="c" >
                                    <p:column>
                                        <h:outputLabel value="#{c.name}"></h:outputLabel>
                                    </p:column>
                                    <p:column>
                                        <h:outputLabel value="#{c.staff.person.nameWithTitle}"></h:outputLabel>
                                    </p:column>
                                    <p:column>
                                        <h:outputLabel value="#{c.billFee.feeValue}"></h:outputLabel>
                                    </p:column>


                                </p:dataTable>

                        
                        </h:panelGrid>


                    </h:panelGrid>

                </p:panel>


            </h:form>
        </h:panelGroup>
    </ui:define>
</ui:composition>
